package com.splunk.hiring.imov.utils;

import java.util.List;

public class PagedData<D> {
	Pager pager;
	List<D> data;

	public PagedData(int pageSize,int pageNumber) {
		Pager pager = new Pager(pageSize,pageNumber);
		this.pager = pager;
	}
	
	public PagedData(Pager pager, List<D> data) {
		super();
		this.pager = pager;
		this.data = data;
	}

	public int getStart() {
		return pager.getStart();
	}
	public int getEnd() {
		return pager.getEnd();
	}
	public Pager getPager() {
		return pager;
	}
	public List<D> getData() {
		return data;
	}
	public void setData(List<D> data) {
		this.data = data;
	}
	
	public static class Pager{
		public static final int DEFAULT_PAGE_SIZE = 10;
		
		private int pageSize;
		private int pageNumber;
		
		private int start;
		private int end;
		
		
		public Pager(int pageSize, int pageNumber) {
			super();
			this.pageSize = pageSize;
			this.pageNumber = pageNumber;
			
			this.start = (pageNumber-1)*pageSize;
			this.end = pageNumber*pageSize-1;
		}
		
		public int getStart() {
			return start;
		}
		public int getEnd() {
			return end;
		}

		public int getPageSize() {
			return pageSize;
		}
		public int getPageNumber() {
			return pageNumber;
		}
	}
	
}
